<?php include PATH_TPL."/admin/tpl.header.phtml"?>
<div class="main-container inner">
    <div class="main-content">
        <div class="container-fluid">
            <div class="row bt">
                <div class="col-lg-12 bg">
                    <ol class="breadcrumb">
                        <li class="active">
                            <i class="fa  fa-fw fa-reorder"></i>人员清单
                        </li>
                    </ol>
                </div>
            </div>
            <div id="page-wrapper">
                <div class="container-fluid col-md-7 col-sx-12">
                        <div class="form-group">
                            <label for="policyno"><strong>保单号</strong></label></br>
                            <span  name="policyno"><?=$tDatas['POLICYNO']?></span>
                        </div>
                        <div class="form-group">
                            <label for="starttime"><strong>产品名称</strong></label></br>
                            <span  name="starttime"><?=$tDatas['product_name']?></span>
                        </div>
                        <div class="form-group">
                            <label for="endtime"><strong>保单人数</strong></label></br>
                            <span  name="endtime"><?=$tCount?></span>
                        </div>
                        <div class="form-group">
                            <label for="insurance_type"><strong>保险期间</strong></label></br>
                            <span  name="product_name"><?=$tDatas['STARTTIME']?>~<?=$tDatas['ENDTIME']?></span>
                        </div>
                       <label><strong>员工信息</strong></label>
                       <div class="row">
                    <form method="get" action="/admin_information/editpolicy?policyno=<?=$tPolicyno?>">
                    <input type='hidden' value='<?=$tPolicyno?>' name='policyno' />
               <!-- <div clas="col-md-4">
-->                   &nbsp;&nbsp;&nbsp;&nbsp;<a class="btn btn-success" id="default" style="height:25px;width:48px;line-height:16px;">重置</a>
                    &nbsp;&nbsp; <select name="policygroup">
                         <option value=''>属组</option><!--保单号需要遍历输出-->
                        <?foreach($tPGDatas as $tPGRow){?>
                        <option value="<?=$tPGRow['policygroup']?>" <?if($tPGRow['policygroup'] == $pPolicygroup){echo 'selected';}?>><?=$tPGRow['policygroupremak']?></option>
<?}?>
                     </select>
                <!--</div>-->                        
                     <input type="text" placeholder="请输入姓名关键字" value="<?=$pKeyWord?>" name="keyword" class="form-controll" style="width:150px;">
                            <span clas="input-group-btn">
                              <button type="button" class="btn btn-default" id="search"><i class="fa fa-search"></i></button>
                            </span>
                          </div>
                        </form>
						<button type="button" class="btn btn-default" id="editfee">修改理赔限额</button>

						<form method="post" style="display:none;" id="excelform">
							<h3>导入Excel表(表头:name、fee['其中name为姓名,fee为理赔限额'])：</h3><input type="file" title="选择文件" name="file_stu" id="file_stu"/>
							<input id="fileBtn" type="submit" value="文件上传">
						</form>
            </div>
            </div></br>
            <div class="panel-body text-center">
                <table class="table table-hover text-center" id="sample-table-1">
                    <thead>
                        <tr>
                            <td>属组</td>
                            <td>姓名</td>
                            <td>证件类型</td>
                            <td>证件号码</td>
                            <td>开户银行</td>
                            <td>银行帐号</td>
                            <td>保单生效日</td>
                            <td>保单截止日</td>
                            <td>员工工号</td>
							<td>是否开放线上理赔</td>
							<td>理赔限额</td>
                            <td>操作</td>
                        </tr>
                    </thead>
                    <?foreach($tPDatas as $tRow){?>
                    <tr>
                        <td><?=$tPGArr[$tRow['insuredgroup']]?></td>
                        <td><?=$tRow['INSUREDNAME']?></td>
                        <td><?=$tIdno[$tRow['crittype']]?></td>
                        <td><?=$tRow['CRITCODE']?></td>
                        <td><?=$tRow['BANK']?></td>
                        <td><?=$tRow['ACCOUNTNO']?></td>
                        <td><?=$tRow['STARTTIME']?></td>
                        <td><?=$tRow['ENDTIME']?></td>
                        <td><?=$tRow['JOBNO']?></td>
						<td><input type="radio" name="authorization<?=$tRow['ID']?>" s="<?=$tRow['ID']?>" value="0" <?php if(empty($tRow['status'])){ echo 'checked';}?>/>是&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" s="<?=$tRow['ID']?>" name="authorization<?=$tRow['ID']?>" value="1" <?php if($tRow['status'] == '1'){ echo 'checked';}?>/>否</td>
                        <td><?=$tRow['fee']?>元</td>
						<td>
                            <div class="visible-md visible-lg hidden-sm hidden-xs">
                                <a href="/admin_information/editUser?policyno=<?=$tPolicyno?>&insuredno=<?=$tRow['INSUREDNO']?>" class="btn btn-blue btn-xs tooltips" data-placement="top" data-original-title="编辑处理"><i class="fa fa-list"></i></a>&nbsp;&nbsp;
                            </div>

                            <div class="visible-xs visible-sm hidden-md hidden-lg">
                                <div class="btn-group">
                                    <a class="btn btn-green dropdown-toggle btn-sm" data-toggle="dropdown" href="#">
                                        <i class="fa fa-cog"></i> <span class="caret"></span>
                                    </a>
                                    <ul role="menu" class="dropdown-menu pull-right dropdown-dark">
                                        <li>
                                            <a role="menuitem" tabindex="-1" href="/admin_information/editUser?policyno=<?=$tPolicyno?>&insuredno=<?=$tRow['INSUREDNO']?>">
                                                <i class="fa fa-edit"></i>编辑处理
                                            </a>
                                        </li>
                                    </ul>
                                </div>
                            </div>
                        </td>

                    </tr>
<?}?>
                    <input type="text" class="id hidden" name="id" value="<?=$pId?>">

                </table>
                <?=$tShow?>
            </div>
        </div>
                </div>
            </div>
        </div>

        <div class="subviews">
            <div class="subviews-container"></div>
        </div>
    </div>
    <!-- end: PAGE -->
</div>
<!-- end: MAIN CONTAINER -->
<script type="text/javascript" src="/plugins/jquery-ui-1.11.4/jquery-ui.min.js"></script>
<script type="text/javascript" src="/plugins/datetimepicker/js/bootstrap-datetimepicker.js"></script>
<script type="text/javascript" src="/plugins/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>
<script type="text/javascript" src="/plugins/base.js"></script>
<script type="text/javascript" src="/plugins/jquery-form.js"></script>
<script type="text/javascript" src="/plugins/jquery.validate.min.js"></script>
<script type="text/javascript">
$('.datetimeEnd').datetimepicker({
    language:  'zh-CN',
    weekStart: 1,
    todayBtn:  1,
    autoclose: 1,
    todayHighlight: 1,
    startView: 2,
    minView: 0,
    format:'yyyy-mm-dd hh:ii',
    pickerPosition: "top-right",
    forceParse: 0
});
</script>


<script>
$(function(){
    var options={
        beforeSubmit : showRequest,    // 提交前的回调函数
        success : showResponse,    // 提交后的回调函数
        dataType : "json",    // html（默认）、xml、script、json接受服务器端返回的类型
    }
    function showRequest(formData, jqForm, options){
        return true;
    }
    function showResponse(responseText,statusText){
            cg_alert_edit(responseText,'/admin_information','/admin_information/editpolicy?policyno=<?=$tDatas['POLICYNO']?>');
    }
    $('#submit').click(function() {
        $('form').ajaxSubmit(options);
        return false;

    });
			/*获取地址栏参数*/
			function GetQuery(key){
				var search = location.search.slice(1);//得到get方式提交的查询字符串
				var arr = search.split("&");
				for(var i = 0; i < arr.length; i++){
					var ar = arr[i].split("=");
					if(ar[0] == key){
						return ar[1];
					}
				}
			}
    $('#search').click(function(){
        $('form').submit();
    });
	$('select').on('change',function(){
		$('#search').trigger('click');		
	});
    $('#default').click(function(){
        var id = $('.id').val();
        window.location.href = '/admin_information/editpolicy?policyno=<?=$tPolicyno?>';
    });
	$('input[type="radio"]').each(function(){
		$(this).on('click',function(){
			var tid = $(this).attr('s');
			var val = $(this).val();
			var policyno = GetQuery('policyno');
			var p = GetQuery('p');
			$.post('/admin_information/editpolicy?policyno='+policyno+'&p='+p,{ "tid":tid,"val":val },function(obj){alert(obj.msg);location.href='/admin_information/editpolicy?policyno='+policyno+'&p='+p;});
		});		
	});
});
$('#editfee').click(function(){
	$('#excelform').css('display','block');		
});
//$('.submit').click(function(){
	var data = document.getElementById('file_stu').value;
	$("#excelform").resetForm().validate({
		rules:{
			"file_stu": {
				required: true,
				accept: "xlsx"
			}
		},
		messages: {
			"file_stu": {
				required: "<font color='red'>请选择上传文件</font>",
				accept: "<font color='red'>文件格式不支持,请上传xls格式的文件</font>"
			}
		},
		submitHandler:function(){
			$("#excelform").ajaxSubmit({
				url:"http://"+domain+"/apiv1_updatefee",
				type:"post",
				enctype:"multipart/form-data",
				contentType:"application/x-www-urlencoded;charset=utf-8",
				//dataType:"json",
				success:function(obj){
					alert(obj.msg);location.reload();	
				},
				error:function(){
					alert('error');
				}
			});	
		}
	});
	/*$.ajax({
		type:'post',
		url:"http://"+domain+"/apiv1_updatefee",
		data:{ "data":data },
		async:false,
		success:function(obj){
			alert(obj.msg);		
		}
	});*/
//});
	var input = document.getElementById('file_stu');
	input.addEventListener('change',readFile,false);
	function readFile(){
		var file = this.files[0];
		console.log(file);return;
		return file;
	}
</script>
<?php include PATH_TPL."/admin/tpl.footer.phtml"?>
